#include<bits/stdc++.h>
using namespace std;
class Solution {
public:
    int k[2]={1,-1};
    int ret=0;
    int n;
    void dfs(vector<int>& nums,int target,int idx,int ans)
    {
        if(idx==n) 
        {
            if(ans==target)
            ret++;
        }
        else
        {
            for(int i=0;i<2;i++)
            {
                dfs(nums,target,idx+1,ans+k[i]*nums[idx]);
            }
        }
    }
    int findTargetSumWays(vector<int>& nums, int target) {
        n=nums.size();
        dfs(nums,target,0,0);
        return ret;
    }
};